The Print Loop

The following code sample shows a basic print loop, updated to use the new Carbon Printing Manager functions.

A Basic Print Loop

PMPrintSettings     mySettings;
PMPageFormat        myFormat;
PMPrintContext      myContext=nil;
PMRect              myPageRect;
Boolean             myResult;
GrafPtr             myGrafPtr;
PMBegin();
    PMNewPrintSettings ( &mySettings );
    PMNewPageFormat ( &myFormat );
    PMDefaultPrintSettings ( mySettings );
    PMDefaultPageFormat ( myFormat );
    /* Here you would set PageFormat fields if necessary. */
    PMPageSetUpDialog ( myFormat, &myResult );
    If ( myResult ) {
        myResult = false;
        /* Here you would set PrintSettings fields if necessary. */
        PMPrintDialog ( mySettings , myFormat, &myResult );
        If ( myResult ) {
            PMBeginDocument ( mySettings, myFormat, &myContext );
            PMBeginPage ( myContext, &myPageRect );
            PMGetGrafPtr ( myContext, &myGrafPtr );
            SetPort ( myGrafPtr );
            /* Image your document. */
            PMEndPage ( myContext );
            PMEndDocument ( myContext );
        }
    }
    PMDisposePageFormat ( myFormat );
    PMDisposePrintSettings ( mySettings );
PMEnd();